* image.c (imagemagick_get_animation_cache): Don't segfault on each invocation.
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 19 Aug 2013 14:52:52 +0000 (16:52 +0200)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 19 Aug 2013 14:52:52 +0000 (16:52 +0200)
Bug introduced by revno 113947, which obviously hadn't even been
tested once.

src/ChangeLog
src/image.c

index 4095d14ab2e9853a33050e7d3efd28d5d765fc11..79c00475ee69103b60d1be62cfbc3652365c222c 100644 (file)
@@ -1,3 +1,8 @@
+2013-08-19  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * image.c (imagemagick_get_animation_cache): Don't segfault on
+       each invocation.
+
 2013-08-19  Paul Eggert  <eggert@cs.ucla.edu>
 
        * image.c: Fix animation cache signature memory leak.
index 68d78fc9eef1536c938706682d66fb68496be3a5..ec89ee076d9cd3d97e48864c4cad1ae3144562fa 100644 (file)
@@ -7927,23 +7927,27 @@ imagemagick_get_animation_cache (MagickWand *wand)
 {
   char *signature = MagickGetImageSignature (wand);
   struct animation_cache *cache;
-  struct animation_cache **pcache = &animation_cache;
+  struct animation_cache **pcache;
 
   imagemagick_prune_animation_cache ();
-  cache = animation_cache;
 
-  for (pcache = &animation_cache; *pcache; pcache = &cache->next)
+  if (! animation_cache)
+    animation_cache = cache = imagemagick_create_cache (signature);
+  else
     {
-      cache = *pcache;
-      if (! cache)
-       {
-         *pcache = cache = imagemagick_create_cache (signature);
-         break;
-       }
-      if (strcmp (signature, cache->signature) == 0)
+      for (pcache = &animation_cache; *pcache; pcache = &cache->next)
        {
-         DestroyString (signature);
-         break;
+         cache = *pcache;
+         if (! cache)
+           {
+             animation_cache = cache = imagemagick_create_cache (signature);
+             break;
+           }
+         if (strcmp (signature, cache->signature) == 0)
+           {
+             DestroyString (signature);
+             break;
+           }
        }
     }